package com.javaspeak.designpatterns.go4.structural.facade;

import com.javaspeak.designpatterns.go4.structural.facade.ShapeFacade;
import com.javaspeak.designpatterns.go4.structural.facade.Square;
import com.javaspeak.designpatterns.go4.structural.facade.SquareBuilder;
import com.javaspeak.designpatterns.go4.structural.facade.SquareBuilderImpl;
import com.javaspeak.designpatterns.go4.structural.facade.Triangle;
import com.javaspeak.designpatterns.go4.structural.facade.TriangleBuilder;
import com.javaspeak.designpatterns.go4.structural.facade.TriangleBuilderImpl;

/**
 * Implements an API to the outside world.  Internally the implementation of
 * the getSquare() and getTriangle() methods make method calls to
 * internal interfaces.  A squareBuilder is used internally to create
 * the square to return and a triangleBuilder is used internally to create
 * the triangle to return.
 *
 * @author John Dickerson
 */
public class ShapeFacadeImpl implements ShapeFacade {

    private SquareBuilder squareBuilder;
    private TriangleBuilder triangleBuilder;


    /**
     * Constructor
     */
    public ShapeFacadeImpl(){

        squareBuilder = new SquareBuilderImpl();
        triangleBuilder = new TriangleBuilderImpl();
    }


    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.structural.facade.
     *      ShapeFacade#getSquare()
     */
    @Override
    public Square getSquare() {

        return squareBuilder.buildSquare();
    }


    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.structural.facade.
     *      ShapeFacade#getTriangle()
     */
    @Override
    public Triangle getTriangle() {

        return triangleBuilder.buildTriangle();
    }
}
